<?php

// +----------------------------------------------------------------------
// | Copyright (c) 2020 All rights reserved.
// +----------------------------------------------------------------------
// | User: Simony <1362229026@qq.com>
// | wechat: Shen86579595
// +----------------------------------------------------------------------

namespace app\common\model\Member;

use app\common\model\Base;
use think\facade\Config;

class RechargeLog extends Base
{
    protected $name = 'member_recharge_log';

    //0:待付款 1:已付款 2:已失效(超过有效付款时间)
    public $states = [
        0 => '待付款',
        1 => '已付款',
        2 => '已失效',
    ];

    //充值方式 1 微信 2 支付宝
    public $recharge_types = [
        0 => '后台',
        1 => '微信',
        2 => '支付宝',
        3 => '苹果',
    ];

    /**
     * User:Simony
     * Function: 列表
     * @param $condition
     * @param int $page
     * @param string $field
     * @param string $order
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \think\exception\DbException
     * @throws db\exception\DataNotFoundException
     * @throws db\exception\ModelNotFoundException
     */
    public function getRechargeLogList($condition = [], $page = 0, $field = '*', $order = 'r.id desc')
    {
        $res = $this->alias('r')
            ->join('member m', 'r.member_id=m.id', 'left')
            ->where($condition)
            ->field($field)
            ->order($order);
        if ($page) {
            $res = $res->paginate($page, false, ['query' => request()->param()]);
            $this->page_info = $res;
            $res = $res->toArray();
            return $res['data'];
        } else {
            return $res->select()->toArray();
        }

    }

}